package com.lykj.llw.box.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lykj.llw.box.R
import com.lykj.llw.box.data.bean.response.GameCouponResponse

/**
 * ================================================
 * 游戏优惠券列表适配器
 * ================================================
 *
 * @author gosha
 * @date 2023/12/11-11:16
 */
class GameCouponAdapter :
    BaseQuickAdapter<GameCouponResponse.DataDTO, BaseViewHolder>(R.layout.item_game_coupon) {
    override fun convert(holder: BaseViewHolder, item: GameCouponResponse.DataDTO) {
        holder.setText(R.id.tv_name, "${item.name}")
        holder.setText(R.id.tv_remark, "${item.excerpt}")
        holder.setText(R.id.tv_amount, "${item.couponMoney}")
        holder.setText(R.id.tv_limit_desc, "满${item.payMoney}可用")

        if (item.isHave) {
            holder.getView<TextView>(R.id.tv_coupon_receiver)
                .setBackgroundResource(R.drawable.shape_half_ff7d7c7a)
            holder.setText(R.id.tv_coupon_receiver, "已领取")
        } else {
            holder.getView<TextView>(R.id.tv_coupon_receiver)
                .setBackgroundResource(R.drawable.shape_half_ff664fc3)
            holder.setText(R.id.tv_coupon_receiver, "领取")
        }
    }
}